<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <div id="app">
        <form action="">
            <div>
                用户名：
                <input type="text" v-on:keyup.delete="handle2" v-model="uname" />
            </div>
            <div>
                密码：
                <input type="text" v-on:keyup.enter="handle1" v-model="pwd" />
            </div>
            <!-- <button @click="handle1">点击提交</button> -->
            <input type="button" @click="handle1" value="点击提交" />
        </form>
    </div>
    <script src="./vue.js"></script>
    <script>
        var vm = new Vue({
            el: ' #app ',
            data: {
                uname: ' ',
                pwd: ' ',
            },
            methods: {
                handle1: function() {
                    console.log(this.uname, this.pwd);
                },
                handle2: function() {
                    this.uname = '';
                },
            },
        });
    </script>
</body>

</html>